<template>
  <div>
    <BasicTable @register="registerTable">
    </BasicTable>
  </div>
</template>
<script lang="ts">
  import {defineComponent} from 'vue';

  import {BasicTable, useTable} from '/@/components/Table';
  import {userGoodsPage} from './api';

  import {useDrawer} from '/@/components/Drawer';

  import {columns, searchFormSchema} from './data';

  export default defineComponent({
    name: 'augManagement',
    components: {BasicTable},
    setup() {
      const [registerDrawer, {openDrawer}] = useDrawer();
      const [registerTable, {reload}] = useTable({
        title: '用户商品表列表',
        api: userGoodsPage,
        columns,
        formConfig: {
          labelWidth: 120,
          schemas: searchFormSchema,
        },
        useSearchForm: true,
        showTableSetting: true,
        bordered: true,
        showIndexColumn: false,
        actionColumn: {
          width: 80,
          title: '操作',
          dataIndex: 'action',
          slots: {customRender: 'action'},
          fixed: undefined,
        },
      });

      function handleCreate() {
        openDrawer(true, {
          isUpdate: false,
        });
      }

      function handleEdit(record: Recordable) {
        openDrawer(true, {
          record,
          isUpdate: true,
        });
      }

      function handleDelete(record: Recordable) {
        console.log(record);
      }

      function handleSuccess() {
        reload();
      }

      return {
        registerTable,
        registerDrawer,
        handleCreate,
        handleEdit,
        handleDelete,
        handleSuccess,
      };
    },
  });
</script>
